﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TestEngine
{
    class Actor
    {
        public String name;
        public Vector2 position;
        public Animation anim;
        public Vector2 orig;
        public Collider collider;

        public Vector2 speed;
        public Vector2 accel;
        public Vector2 grav;

        public Actor()
        {
            speed = Vector2.Zero;
            accel = Vector2.Zero;
            grav = Vector2.Zero;
        }

        public Actor(Vector2 _pos)
        {
            position = _pos;
            collider = new Collider(position, new Vector2(1, 1));
            speed = Vector2.Zero;
            accel = Vector2.Zero;
            grav = Vector2.Zero;
        }
        public Actor(Vector2 _pos, Animation _anim)
        {
            position = _pos;
            anim = _anim;
            collider = new Collider(position, new Vector2(1, 1));
            speed = Vector2.Zero;
            accel = Vector2.Zero;
            grav = Vector2.Zero;
        }
        public Actor(Vector2 _pos, Animation _anim, Vector2 _orig)
        {
            position = _pos;
            anim = _anim;
            orig = _orig;
            collider = new Collider(position, new Vector2(1, 1));
            speed = Vector2.Zero;
            accel = Vector2.Zero;
            grav = Vector2.Zero;
        }
        public Actor(Vector2 _pos, String _name)
        {
            name = _name;
            position = _pos;
            collider = new Collider(position, new Vector2(1, 1));
            speed = Vector2.Zero;
            accel = Vector2.Zero;
            grav = Vector2.Zero;
        }

        public virtual void update(int d_time)
        {
            position += speed * d_time;

            if (collider != null)
            {
                collider.update(d_time, this);
            }

            anim.update(d_time);

            speed += (grav - accel) * d_time;
            if (accel.Y > 0)
            {
                accel.Y -= 0.01f;
            }
            if (accel.Y < 0)
            {
                accel.Y = 0;
            }
        }
    }
}